#include <iostream>
using namespace std;
class Book{
private:
    //构造函数
    string bookname;
    int price;
    int number;
public:
    void disp();
    void borrow();
    void restroe();
    Book(string name,int p,int n);
};
Book::Book(string name,int p,int n)
{
    bookname=name;
    price=p;
    number=n;
}

void Book::borrow() {
    number-=1;
}

void Book::restroe() {
    number+=1;
}

void Book::disp() {
    cout<<bookname<<"剩余的数量"<<number<<endl;
}
int main()
{
    string name1,choice;
    string a="借书";
    int price1,number1,n;
    cout<<"输入书的名字"<<endl;
    cin>>name1;
    cout<<"请分别输入书的单价和剩余数量"<<endl;
    cin>>price1>>number1;
    Book b1(name1,price1,number1);
    b1.disp();
    while (1){
        cout<<"需要借书还是还书"<<endl;
        cin>>choice;
        if(choice == a){
            b1.borrow();
            b1.disp();
        }else{
            b1.restroe();
            b1.disp();
        }
    }
}

